import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../../home.dart';
import '../../../../shared/shared.dart';

class HomeAvatar extends GetView<HomeLogic> {
  final double size;
  final String imageURL;
  final double avatarSize;

  const HomeAvatar({
    Key? key,
    this.size = 50,
    required this.imageURL,
    this.avatarSize = 44,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Stack(
      alignment: Alignment.center,
      children: [
        SizedBox(width: size + 10, height: size + 10),
        Container(
          width: size,
          height: size,
          decoration: const BoxDecoration(
            color: ColorConstants.themeColor,
            borderRadius: BorderRadius.all(Radius.circular(15)),
          ),
        ),
        Container(
          width: avatarSize,
          height: avatarSize,
          decoration: BoxDecoration(
              borderRadius: const BorderRadius.all(Radius.circular(15)),
              image: DecorationImage(image: AssetImage(imageURL))),
        ),
        Obx(() => Positioned(
              right: 0,
              bottom: 0,
              child: Container(
                width: 20,
                height: 20,
                decoration: BoxDecoration(
                  color: controller.state.onLine.value
                      ? ColorConstants.selectColor
                      : ColorConstants.underlineColor,
                  shape: BoxShape.circle,
                  border: Border.all(color: ColorConstants.themeColor, width: 2),
                ),
              ),
            ))
      ],
    );
  }
}
